


#[cfg(feature = "avx")] 
use superfeature_avx::Sha1Avx2;
#[cfg(feature = "avx")] 
pub type DefaultFingerprintType = Sha1Avx2;

#[cfg(not(feature = "avx"))]
pub type DefaultFingerprintType = [u8;util::SHA1];

pub type DefaultChunkPointer = crate::recipe::FpPointer;
pub type DefaultKvStore = sled::Db;

//backup constants
pub const BACKUP_READ_BUF_LEN:usize = 0x100_000; 	//size of read buffer in backup procedure	1MB  2^20
pub const BACKUP_SPLIT_BUF_LEN:usize =  0x10_000;	//size of split chunk in backup procedure	64KB 2^16

pub const FIXED_CHUNK_LEN:usize = 0x1000;	//size of fixed chunking 

//index constants
pub const INDEX_DIR_NAME:&str = "index";
pub const INDEX_FP_STORE_NAME:&str = "fpstore";
pub const INDEX_SF_STORE_NAME:&str = "sfstore";
pub const INDEX_FP_STORE_INFO_LEN:usize = 0x10;
pub const INDEX_SF_STORE_INFO_LEN:usize = 0x01;
pub const INDEX_SF_ONE_KEY:[u8;3] = *b"sf1";
pub const INDEX_SF_TWO_KEY:[u8;3] = *b"sf2";
pub const INDEX_SF_THREE_KEY:[u8;3] = *b"sf3";
pub const INDEX_SF_FOUR_KEY:[u8;3] = *b"sf4";
pub const INDEX_SF_KEYS:[[u8;3];4] = [INDEX_SF_ONE_KEY,INDEX_SF_TWO_KEY,INDEX_SF_THREE_KEY,INDEX_SF_FOUR_KEY];

//container constants
pub const CONTAINER_SIZE:usize = 0x400_000;	//size of container				4MB 2^22
pub const WRITE_BUFFER_LEN:usize = 0x10;	//max num of container in store write buffer	16  2^4
pub const CACHE_SIZE:usize = 0x80;		//max num of container in store read buffer	128 2^7
pub const CONTAINER_FILE_NAME:&str = "container.pool";	//file name of container

//xcontainer constants
pub const XCONTAINER_LEN:usize = 0x200;	//len of container 1024	
pub const XCONTAINER_META_LEN:usize = 0x200;	//len of container 1024	
pub const XCONTAINER_DIR:&str = "container";	//directory name of container
pub const XCONTAINER_META_NAME:&str = "meta";	//file name of container meta
pub const XCONTAINER_POOL_NAME:&str = "pool";	//file name of container pool

//recipe constants
pub const FILE_RECORD_BUF_LEN:usize = 0x1000;	//file info recipe write/read buffer len
pub const SEG_RECORD_BUF_LEN:usize = 0x1000;	//chunk pointer recipe write/read buffer len
pub const CON_RECORD_BUF_LEN:usize = 0x1000;	//container id recipe write/read buffer len

pub const RECIPE_DIR_NAME:&str = "recipe";			//dir name of recipe
pub const FILE_INFO_RECIPE_NAME:&str = "recipe.file";	//file name of file info recipe
pub const SEGMENT_RECIPE_NAME:&str = "recipe.seg";	//file name of chunk pointer recipe
pub const CONTAINER_RECIPE_NAME:&str = "recipe.con";	//file name of container id recipe

//version control constants
pub const VERSION_DIR_NAME:&str = "version"; //name of db which is use to control version
pub const VERSION_ALL_KEY:&str = "version all";
pub const VERSION_NUM_KEY:&str = "version num"; //the key to get num of version
pub const VERSION_DEFAULT_KEY:&str = "default version"; //the key to get default version direactory
pub const HALF_CONTAINER_INFO_KEY:&str = "half container info"; //the key to get info of container which is the last container in last backup

//log file
pub const BACKUP_FILE_RECIPE_LOG:&str = "backup/recipe";			//backup stage log of file info recipe write
pub const BACKUP_CHUNK_POINTER_RECIPE_LOG:&str = "backup/recipe";	//backup stage log of chunk pointer recipe write
pub const BACKUP_CONTAINER_ID_RECIPE_LOG:&str = "backup/recipe";	//backup stage log of container id recipe write

pub const BACKUP_CONTAINER_LOG:&str = "backup/container";			//backup stage log of container write
pub const BACKUP_DEDUP_LOG:&str = "backup/dedup";
pub const BACKUP_MATCHING_LOG:&str = "backup/matching";

pub const RESTORE_FILE_RECIPE_LOG:&str = "restore/recipe";
pub const RESTORE_CHUNK_POINTER_RECIPE_LOG:&str = "restore/recipe";
pub const RESTORE_CONTAINER_ID_RECIPE_LOG:&str = "restore/recipe";

pub const RESTORE_CONTAINER_LOG:&str = "restore/container";
pub const RESTORE_DECODE_LOG:&str = "restore/decode";



fn _assert_finger_print_hasher<T>() where T:util::FingerPrintHasher {}
fn _assert_kvstore<T>() where T:crate::index::fp_kvstore::FpKvStore {}
fn _assert_chunk_pointer<T>() where T:crate::recipe::ChunkPointer {}
fn _assert_collection() {
	_assert_finger_print_hasher::<DefaultFingerprintType>();
	_assert_kvstore::<DefaultKvStore>();
	_assert_chunk_pointer::<DefaultChunkPointer>();
	assert!(BACKUP_READ_BUF_LEN >= BACKUP_SPLIT_BUF_LEN);
}
